package com.wawu.controller;

import com.wawu.annotation.controller.Mapping.GetMapping;
import com.wawu.annotation.controller.Mapping.PostMapping;
import com.wawu.annotation.controller.Mapping.RequestMapping;
import com.wawu.annotation.IOC.component.RestController;
import com.wawu.annotation.parameter.RequestBody;
import com.wawu.annotation.parameter.RequestParam;
import com.wawu.pojo.Result;


import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api")
public class TestController {
    @GetMapping("/hello")
    public String hello() {
        return "Hello, World!";
    }

    @PostMapping("/data")
    public String postData() {
        return "Data posted successfully";
    }

    @GetMapping("/get")
    public Object getMap(){
        Map<String,Object> map=new HashMap<>();
        map.put("code",1);
        map.put("data","11111");
        return map;
    }
    @GetMapping("/getResult")
    public Object getResult(){
        Result result=new Result();
        result.setCode(1);
        result.setMsg("success");
        return result;
    }

    @GetMapping("/getParameter")
    public Object solveParamter(@RequestParam("value") Integer id){
        Result result=new Result();
        result.setCode(id);
        result.setMsg("success");
        return result;
    }

    @PostMapping("/aaa")
    public Object aaa(@RequestBody() Result result){
        return result;
    }
}
